/**
 * @author mihail
 */
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;

import weapon.WeaponView;

public class TestView extends MovieClip {
    private static var RAD_TO_DEG:Number = 180 / Math.PI;
    private static var DEG_TO_RAD:Number = Math.PI / 180;
    private static var weaponView:WeaponView;

    public function TestView() {
        weaponView = new WeaponView();
        addChild(weaponView);
        weaponView.x = stage.stageWidth / 2;
        weaponView.y = stage.stageHeight / 2;
        addEventListener(Event.ENTER_FRAME, gunFireballGuidance);
    }

    private function gunFireballGuidance(e:Event):void {
        var angle:int = Math.atan2(mouseY - (weaponView.y + weaponView.gunFireball.gun.y), mouseX - weaponView.x) * RAD_TO_DEG;
        if (angle < 0){
            angle = 180 + (180 + angle);
        }
        weaponView.gunFireball.gun.gotoAndStop(angle + 1);
    }
}
}

